<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
/**
 *
 * functions.php template file
 *
 * (c) 2011 by Mike Walsh
 *
 * @author Mike Walsh <mike@walshcrew.com>
 * @package CASL-Soccer-2011
 * @subpackage functions
 * @version $Revision$
 * @lastmodified $Author$
 * @lastmodifiedby $Date$
 *
 */

/**
 * Add support for mobile menus by incorporating
 * the Dropdown-Menus plugin as part of the theme.
 */

if ( ! function_exists( 'dropdown_menu' ) )
    include( 'dropdown-menus/dropdown-menus.php' );

/**
 * Setup theme support
 */
add_theme_support( 'custom-header', array(
    // Header image default
    //'default-image'         => get_template_directory_uri() . '/images/headers/default.jpg',
    'default-image'         =>  get_stylesheet_directory_uri() . '/images/CASL/CASL_Bg_Header.jpg',
    // Header text display default
    'header-text'           => true,
    // Header text color default
    'default-text-color'        => '000',
    // Header image width (in pixels)
    'width'             => 1024,
    // Header image height (in pixels)
    'height'            => 101,
    // Header image random rotation default
    'random-default'        => false,
    // Template header style callback
    'wp-head-callback'      => '_custom_background_cb',
    // Admin header style callback
    'admin-head-callback'       => '',
    // Admin preview style callback
    'admin-preview-callback'    => ''
) );
    
/**
 * Favorite Icon filter
 *
 */
function casl_favicon()
{
    echo '<link rel="shortcut icon" href="' .
        get_stylesheet_directory_uri() . '/images/soccer/favicon.ico" />' ;
}
add_action('wp_head', 'casl_favicon') ;
	
/**
 * Return the path to the theme's header image.
 *
 * @return string - path to theme header image
 * @uses get_theme_root_uri()
 */
function casl_child_theme_header_image() {
	return get_theme_root_uri() . '/images/CASL/CASL_Bg_Header.jpg' ;
}

//  Add the 'theme_mod_header_image' filter
add_filter('theme_mod_header_image', 'casl_child_theme_header_image') ;


//  Load CASL extensions
require_once(get_stylesheet_directory() . '/header.inc.php') ;
require_once(get_stylesheet_directory() . '/options.inc.php') ;

//add_filter( 'twentyeleven_color_schemes', 'twentyeleven_color_schemes_casl' );
//add_action( 'twentyeleven_enqueue_color_scheme', 'twentyeleven_enqueue_color_scheme_casl' );

/*
function twentyeleven_color_schemes_casl( $color_schemes ) {
	$color_schemes['casl'] = array(
		'value' => 'casl',
		'label' => __( 'Orange', 'twentyeleven' ),
		'thumbnail' => get_stylesheet_directory_uri() . '/casl.png',
		'default_link_color' => '#FFA500',
	);
	return $color_schemes;
}
 */

/*
function twentyeleven_enqueue_color_scheme_casl( $color_scheme ) {
	if ( 'casl' == $color_scheme )
		wp_enqueue_style( 'casl', get_stylesheet_directory_uri() . '/css/casl.css', array(), null );
}
 */

/**
 * CASL Theme change default headers
 *
 * The TwentyEleven theme has a default set of headers that it ships
 * with which we don't want.  The default headers are unregistered and
 * the CASL header is registered in their place.  Support for custom
 * headers and backgrounds are also disabled to ensure a consistent
 * look across any site using this theme.
 *
 * @return void
 * @uses register_default_headers()
 * @uses unregister_default_headers()
 * @uses remove_custom_background()
 * @uses remove_custom_image_header()
 */
function casl_change_default_headers()
{
    unregister_default_headers(
        array(
            'wheel',
            'shore',
            'trolley',
            'pine-cone',
            'chessboard',
            'lanterns',
            'willow',
            'hanoi'
        )
    );
    register_default_headers( array(
        'header' => array(
            'url' => get_stylesheet_directory_uri() . '/images/CASL/CASL_Bg_Header.jpg',
            'thumbnail_url' => get_stylesheet_directory_uri() . '/images/CASL/CASL_Bg_Header-thumbnail.jpg',
            /* translators: header image description */
            'description' => __( 'CASL', 'twentyeleven-child' )
        )
    ) );

    //  Disable custom page backgrounds
    //remove_custom_background() ;
    //remove_theme_support( 'custom-background' ) ;

    //  Disable custom header images
    //remove_custom_image_header() ;
    //remove_theme_support( 'custom-header' ) ;

	global $_wp_theme_features;
	unset($_wp_theme_features['custom-header']);
	unset($_wp_theme_features['custom-background']);
    
}
 
//  Set up the 'after_setup_theme' action
add_action( 'after_setup_theme', 'casl_change_default_headers');

/**
 * CASL Theme header image width
 *
 * @return int - width of header image
 */
function casl_header_image_width($param)
{
    return 1024 ;
}

//  Set up the header width filter
add_filter('twentyeleven_header_image_width', 'casl_header_image_width') ;

/**
 * CASL Theme header image height
 *
 * @return int - height of header image
 */
function casl_header_image_height($param)
{
    return 101 ;
}

//  Set up the header height filter
add_filter('twentyeleven_header_image_height', 'casl_header_image_height');

/**
 * Custom Login Screen
 *
 * Output CSS to customize the login page.
 * 
 * @return void
 */
function casl_custom_login()
{ 
    echo '<link rel="stylesheet" type="text/css" href="' .
        get_stylesheet_directory_uri() . '/css/login.css" />' ;
}

//  Add login_head action
add_action('login_head', 'casl_custom_login');

/**
 * CASL Theme body class filter
 *
 * @param array $classes - array of body classes.
 * @return array $classes - array of body classes.
 * @uses get_page_template()
 */
function casl_theme_body_class($classes)
{
    //  The latest-news-template.php Page Template is derived from
    //  TwentyEleven's showcase.php so we want to add the proper body
    //  class in order to leverage the CSS that already exists but only
    //  on a Page so check that first!

    if (is_page() && (basename(get_page_template()) === 'latest-news-template.php'))
        $classes[] = 'page-template-showcase-php' ;

    return $classes ;
}

//  Add body_class filter
add_filter('body_class', 'casl_theme_body_class') ;
?>
